<template>
	<view class="content">
		<view class="top">
				<view class="uni-padding-wrap">
					<view class="page-section swiper">
						<view class="page-section-spacing">
							<swiper class="swiper" :indicator-dots="indicatorDots" :autoplay="autoplay" :interval="interval" :duration="duration">
								<swiper-item v-for="(item,index) in bannerList" >
									<navigator :url="item.linkUrl">  
										<image :src="apiurl+item.img" class="swiperItem"></image>
									</navigator>
								</swiper-item>
								
							</swiper>
						</view>
					</view>
				</view>
		</view>
		
		<view class="menu">
			<uni-grid :column="4" :showBorder="false"  :square="false" :highlight="true" >
				<uni-grid-item v-for="(item, index) in menuList" :index="index" :key="index">
					<view v-if="index < 8" class="grid-item-box">
						<navigator :url="item.linkUrl">  
							<image :src="apiurl+item.img" class="menu-image" mode="aspectFill"/>
						</navigator>
					<text class="menu-text">{{item.name}}</text>
					</view>
				</uni-grid-item>
			</uni-grid>
		</view>
		<view style="width:100%;">
		  <official-account style="top:0;width:81%;height:168rpx;"></official-account>
		</view>

		<view class="notice">
			<view class="section">
				<view class="section-head">
					<view class="section-head-tag"></view>
				</view>
				<view class="section-content">
					<uni-row>
						<uni-col :span="20"><text>寺庙动态</text></uni-col>
						<uni-col style="text-align: right;" :span="4">
							<text @click="navTo('/pages/news/category')">更多></text>
						</uni-col>
					</uni-row>
					
				</view>
			</view>
			<uni-list :border="true" v-for="(item, index) in list" >
				<uni-list-chat v-if="index<3" :title="item.title" :avatar="apiurl+item.img" :note="item.description" :time="item.createTime" :clickable="true" :showTime="true" @click="navTo('/pages/news/detail?id='+item.id+'&title='+item.title)"></uni-list-chat>
			</uni-list>
		</view>
	
		<view class="donation">
			<view class="section">
				<view class="section-head">
					<view class="section-head-tag"></view>
				</view>
				<view class="section-content">
					<uni-row>
						<uni-col :span="20"><text>建寺安僧</text></uni-col>
						<uni-col style="text-align: right;" :span="4">
							<text @click="navTo('/pages/donation/category')">更多></text>
						</uni-col>
					</uni-row>
				</view>
			</view>
			<view>
				<uni-row>
					<uni-col :span="12" v-for="(item,index) in list3">
						<uni-card v-if="index<4" :border="false" spacing="0" margin="5px">
							<view  class="align-center" @click="navTo('/pages/donation/detail?id='+item.id+'&title='+item.name)">
								<image style="width: 100%;height: 100px;" :src="apiurl+item.img"></image>
								<text class="uni-body uni-mt-5">{{item.name}}</text>
							</view>
						</uni-card>
					</uni-col>
				</uni-row>
			</view>
		</view>
		
		<view class="notice">
			<view class="section">
				<view class="section-head">
					<view class="section-head-tag"></view>
				</view>
				<view class="section-content">
					<uni-row>
						<uni-col :span="20"><text>活动报名</text></uni-col>
						<uni-col style="text-align: right;" :span="4">
							<text @click="navTo('/pages/activity/category')">更多></text>
						</uni-col>
					</uni-row>
				</view>
			</view>
			<uni-list :border="true" v-for="(item, index) in list2" >
				<uni-list-chat  v-if="index<3" :title="item.title" :avatar="apiurl+item.img" noteIcon="icon-kaishishijian" :note="item.beginTime" note2Icon="icon-jieshushijian" :note2="item.endTime" note3Icon="location" :note3="item.location" :showTime="false" :time="item.createTime" :clickable="true" @click="navTo('/pages/activity/detail?id='+item.id+'&title='+item.title)"></uni-list-chat>
			</uni-list>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				apiurl:'',
				title: 'Hello',
				background: ['uni-bg-red', 'uni-bg-green', 'uni-bg-blue'],
				bannerList:[],
				indicatorDots: true,
				autoplay: true,
				interval: 2000,
				duration: 500,
				list:[],
				list2:[],
				list3:[],
				menuList:[]
				
			}
		},
		onLoad:function(option){
			this.apiurl = getApp().globalData.staticUrl
			//加载banner
			this.$http.get('/temple.appearance/templeAppearanceBanner/api/list', {
				'location':'index'
			}).then((res) => {
				this.bannerList = res.data.result.records;
			})
			
			//加载按钮
			this.$http.get('/temple.appearance/templeAppearanceMenu/api/list', {
				'sysOrgCode':getApp().globalData.orgCode
			}).then((res) => {
				console.log(res)
				this.menuList = res.data.result.records;
			})
			
			//加载新闻
			this.$http.get('/temple.news/templeNews/api/list', {
				'sysOrgCode':getApp().globalData.orgCode
			}).then((res) => {
				this.list = res.data.result.records;
			})
			//加载活动
			this.$http.get('/temple.activity/templeActivity/api/list', {
				'sysOrgCode':getApp().globalData.orgCode
			}).then((res) => {
				this.list2 = res.data.result.records;
			})
			//加载供养
			this.$http.get('/temple.donation/templeDonation/api/list', {
				'sysOrgCode':getApp().globalData.orgCode
			}).then((res) => {
				this.list3 = res.data.result.records;
			})
			
			
		},
		methods: {
			changeIndicatorDots(e) {
				this.indicatorDots = !this.indicatorDots
			},
			changeAutoplay(e) {
				this.autoplay = !this.autoplay
			},
			intervalChange(e) {
				this.interval = e.target.value
			},
			durationChange(e) {
				this.duration = e.target.value
			},
			goTo(item){
				this.navTo(item.linkUrl)
			}
		}
	}
</script>

<style>
	.align-right{
		text-align: right;
	}
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.logo {
		height: 200rpx;
		width: 200rpx;
		margin-top: 200rpx;
		margin-left: auto;
		margin-right: auto;
		margin-bottom: 50rpx;
	}

	.text-area {
		display: flex;
		justify-content: center;
	}

	.title {
		font-size: 36rpx;
		color: #8f8f94;
	}
	.uni-bg-red{
		background-color: red;
		height: 100%;
	}
	.uni-bg-green{
		background-color: green;
		height: 100%;
	}
	.uni-bg-blue{
		background-color: blue;
		height: 100%;
	}
	.top{
		width: 100%;
	}
	.menu{
		width: 100%;
		text-align: center;
		
	}
	.menu-item{
		width: 25%;
		/* border:1rpx solid #999999; */
		float: left;
		text-align: center;
		height:160rpx;
		line-height: 160rpx; 
	}
	.notice{
		width: 100%;
		height: auto;
	}
	.notice-body-item{
		position: relative;
		display: flex;
		flex-direction: row;
		align-items: center;
		padding: 10rpx 10rpx;
		border-bottom: #C0C0C0 1rpx solid;
	}
	.notice-row{
		width: 100%;
		height: 160rpx;
		/* padding: 0px 10rpx 5rpx 10rpx; */
		
		
	}
	.notice-row-col{
		max-height: 100%;
		padding:3rpx 3rpx;
		overflow: hidden;
	}
	.notice-row-col-img{
		max-width: 95%;
		height: 160rpx;
	}
	.notice-text-title{
		font-size: 16px;
		color: #3b4144;
		font-weight: 400;
		text-overflow: -o-ellipsis-lastline;
		 overflow: hidden;
		 text-overflow: ellipsis;
		 display: -webkit-box;
		 -webkit-line-clamp: 1; //可设置显示的行数
		 line-clamp: 1;
		 -webkit-box-orient: vertical;
	}
	.notice-text-note{
		margin-top: 3px;
		color: #999;
		font-size: 12px;
		font-weight: 400;
		text-overflow: -o-ellipsis-lastline;
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-line-clamp: 2; //可设置显示的行数
		line-clamp: 1;
		-webkit-box-orient: vertical;
	}
	.notice-text-note-oneline{
		margin-top: 3px;
		color: #999;
		font-size: 12px;
		font-weight: 400;
		text-overflow: -o-ellipsis-lastline;
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-line-clamp: 1; //可设置显示的行数
		line-clamp: 1;
		-webkit-box-orient: vertical;
	}
	.notice-text-note-time{
		margin-top: 10px;
		color: #999;
		font-size: 12px;
		font-weight: 400;
		text-align: right;
		display: -webkit-box;
		-webkit-box-orient: vertical;
	}
	
	.section{
		position: relative;
		display: flex;
		flex-direction: row;
		align-items: center;
		padding: 5rpx 10rpx;
		font-weight: 400;
		
	}
	.section-head{
		flex-direction: row;
		justify-content: center;
		align-items: center;
		margin-right: 10px;
	}
	.section-head-tag{
		height: 12px;
		background-color: #2979ff;
		border-radius: 10px;
		width: 4px;
	}
	.section-content{
		display: flex;
		flex-direction: column;
		flex: 1;
		color: #333;
	}
	.section-content-more{
		text-align: right;
	}
	.donation{
		width: 100%;
	}
	.donation-body{
		background-color: #2979FF;
	}
	.grid-item-box {
			flex: 1;
			// position: relative;
			/* #ifndef APP-NVUE */
			display: flex;
			/* #endif */
			flex-direction: column;
			align-items: center;
			justify-content: center;
			padding: 15px 0;
		}
	.menu-image {
			width: 40px;
			height: 40px;
			border-radius: 50%;
		}
	
	.menu-text {
		font-size: 14px;
		margin-top: 5px;
	}
	
	.swiperItem{
		width: 100%;
		/* height: 320px; */
	}
</style>
